﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    public class solution5
    {
        public int Reverse(int x)
        {
            long sum = 0;
            while (x != 0)
            {
                sum = sum * 10 + x % 10;
                x /= 10;
            }
            if (sum > int.MaxValue || sum < int.MinValue)
            {
                return 0;
            }
            else
            {
               
                return (int)sum;
               
            }
        }
    }
}
